package com.lanhe.teacher.service.impl;

import com.lanhe.common.constant.Constants;
import com.lanhe.common.utils.StringUtils;
import com.lanhe.teacher.domain.LhTeacher;
import com.lanhe.teacher.domain.vo.StatTeacherByGroupVo;
import com.lanhe.teacher.mapper.LhTeacherMapper;
import com.lanhe.teacher.service.ILhTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 老师表(LhTeacher)表服务实现类
 *
 * @author zhanggl
 * @since 2023-09-14 22:28:47
 */
@Service
public class LhTeacherServiceImpl implements ILhTeacherService {

	@Autowired
	private LhTeacherMapper teacherMapper;

	/**
	 * 根据条件分页查询老师列表
	 *
	 * @param teacher 用户信息
	 * @return 老师信息集合信息
	 */
	@Override
	public List<LhTeacher> selectTeacherList(LhTeacher teacher) {
		return teacherMapper.selectTeacherList(teacher);
	}

	/**
	 * 查询老师信息
	 *
	 * @param teacherId 老师ID
	 * @return 老师信息
	 */
	@Override
	public LhTeacher selectTeacherById(Long teacherId) {
		return teacherMapper.selectTeacherById(teacherId);
	}

	/**
	 * 查询组信息批量
	 *
	 * @param teacherId 组IDs
	 * @return 组信息
	 */
	@Override
	public List<LhTeacher> selectTeacherByIds(Long[] teacherId) {
		return teacherMapper.selectTeacherByIds(teacherId);
	}

	/**
	 * 查询老师名称是否存在
	 *
	 * @param teacher 用户信息
	 * @return 结果
	 */
	@Override
	public boolean checkTeacherNameUnique(LhTeacher teacher) {
		LhTeacher info = teacherMapper.checkTeacherNameUnique(teacher.getTeacherName(),teacher.getGroupId(),teacher.getTeacherId());
		if (StringUtils.isNotNull(info))
		{
			return Constants.NOT_UNIQUE;
		}
		return Constants.UNIQUE;
	}

	/**
	 * 新增老师信息
	 *
	 * @param teacher 老师信息
	 * @return 结果
	 */
	@Override
	public int insertTeacher(LhTeacher teacher) {
		return teacherMapper.insertTeacher(teacher);
	}

	/**
	 * 修改老师信息
	 *
	 * @param teacher 参数老师信息
	 * @return 结果
	 */
	@Override
	public int updateTeacher(LhTeacher teacher) {
		return teacherMapper.updateTeacher(teacher);
	}

	/**
	 * 批量删除老师信息
	 *
	 * @param teacherIds 需要删除的参数ID
	 * @return 结果
	 */
	@Override
	public int deleteTeacherByIds(Long[] teacherIds) {
		return teacherMapper.deleteTeacherByIds(teacherIds);
	}

	/**
	 * 根据小组ID统计老师数量
	 *
	 * @param groupIds 小组ID
	 * @return 结果
	 */
	@Override
	public List<StatTeacherByGroupVo> statTeacherByGroupIds(List<Long> groupIds) {
		return teacherMapper.statTeacherByGroupIds(groupIds);
	}
}

